# Build recipe for pinentry
#
# Copyright 2016,2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
#
# This recipe is free software, under the terms of the Apache License 2.0

program=pinentry
version=0.9.7
release=1

description="
pinentry is a small collection of dialog programs that allow GnuPG to
read passphrases and PIN numbers in a secure manner. There are
versions for the common GTK and Qt toolkits as well as for the text
terminal (Curses).
"

homepage=https://www.gnupg.org/related_software/pinentry/index.en.html
license=GPLv2

tarname=${program}-${version}.tar.bz2

# Remote source(s)
fetch=https://www.gnupg.org/ftp/gcrypt/pinentry/$tarname

# Source documentation
docs="AUTHORS COPYING NEWS README* THANKS TODO VERSION"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"
    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --infodir=$infodir \
    --docdir=$docdir \
    --build="$(cc -dumpmachine)" \
    --enable-pinentry-curses \
    --disable-pinentry-gtk2 \
    --disable-pinentry-qt \
    --disable-pinentry-gnome3

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi
    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs ; do
            cp -p $file "${destdir}${docsdir}"
	        done
}
